<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/settingForecast.do"/>

<%@ page import="com.scalar.chiptrack.users.User,
                 com.scalar.chiptrack.users.UserGroup,
                 java.util.Calendar,
                 com.scalar.chiptrack.utils.ConfigManager"%>

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js">
</script>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>
<SCRIPT language="JavaScript">
    var marketing = '<%=request.getParameter("marketing")%>';
    function submitPage()
    {

        var customerId = document.settingForecastForm.customer.value;
        var productId  = document.settingForecastForm.product.value;
        var monthId    = document.settingForecastForm.startMonth.value;
        var yearId     = document.settingForecastForm.year.value;
        var month_count = document.settingForecastForm.monthCount;
        var errors = '';


        if (customerId == 'All Customers' && marketing !='on' )
        {
            errors = '<li> Please select the customer';
        }
        if (productId == '-1')
        {
            errors = errors + '<br>' + '<li> Please select the product';
        }
        if (monthId == '-1')
        {
            errors = errors + '<br>' + '<li> Please select the Start Month';
        }
        if (yearId == '-1')
        {
            errors = errors + '<br>' + '<li> Please select the Year';
        }
        if( month_count.value < '1')
        {
            errors = errors +'<br>' + "<li>  Please enter Valid value in Show next months";
            month_count.select();
        }
        else if( !isInteger( month_count.value ) )
        {
             errors = errors +'<br>' + "<li>  Please enter a valid Months";
             month_count.select();
        }
        if(errors != '')
        {
            pa=document.getElementById("font1");
            pa.innerHTML = errors;
            return false;
        }

        document.settingForecastForm.action.value = "loadForecast";
        //document.settingForecastForm.submit();
       return true;

    }
    function openWindow()
    {
        newWindow = window.open('<%=chipTracContext%>/uploadForecast.do','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=no,width=600,height=400,left=300,top=40');
  	    newWindow.focus();
    }
    //added by varma
    function loadEndUser()
    {
        document.settingForecastForm.action.value = "loadEndUser";
        document.settingForecastForm.marketing.value = "";
        document.settingForecastForm.submit();
    }

</SCRIPT>

<!-- Top Header Start-->

<%@ include file="/jsp/includes/header.jsp" %>

<!-- Top Header End-->


<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
    <TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->

    <%@ include file="/jsp/marketing/marketing_menu.jsp" %>

    </TD>
<!-- end of the side navigations -->
<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>

<!-- from here your body starts -->
<html:form name="settingForecastForm" method="post" action="/settingForecast" type="com.scalar.chiptrack.sales.forms.SettingForecastForm" onsubmit = "javasript:return submitPage();">
<html:hidden name="settingForecastForm" property="showMkgForecast"/>
<table border=0 cellspacing=0 cellpadding=4 width='98%' align=right class="NArialL">
    <logic:equal name="settingForecastForm" property="showMkgForecast" value="on">
         <tr><td colspan=5 class="NArialW" align='center'> Marketing Forecast </TD></TR>
    </logic:equal>
    <logic:notEqual name="settingForecastForm" property="showMkgForecast" value="on">
        <tr><td colspan=5 class="NArialW" align='center'> Sales Forecast </TD></TR>
    </logic:notEqual>
    <tr><td colspan=5><BR></td></tr>
    <tr><td colspan=5><chiptrack:info styleClass="NArialL"/></td></tr>
    <tr><td colspan=5><chiptrack:errors styleClass="NArialL"/><FONT id='font1' color='#FF0000'></td></tr>
    <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td valign="top">
                <logic:equal name="settingForecastForm" property="showMkgForecast" value="on">
                      <font class=NArialS>
                      <chiptrack:restrictedLink functionality='<%=Functionality.SETTING_MARKETING_FORECAST%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:openWindow();"  onmouseover="window.status='Click to Upload File';return true" onmouseout="window.status='';return true">
                      Click here to upload file</chiptrack:restrictedLink> </font>
                </logic:equal>
        </td>
    </tr>
    <tr><td colspan=5><BR></td></tr>
    <tr>
        <td width="15%"> Customer: </td>

        <td width="20%">
            <logic:notEqual name="settingForecastForm" property="showMkgForecast" value="on">
            <html:select name="settingForecastForm" property="customer" styleClass="txfield" onchange= "javaScript:loadEndUser()">
                <option value="All Customers">-- Select Customer --</option>
                <option value="All Customers"></option>
                <html:option value="Others">-- Others --</html:option>
                <html:options collection="customerList" property="value" labelProperty="label"/>
            </html:select>
           </logic:notEqual>
            <logic:equal name="settingForecastForm" property="showMkgForecast" value="on">
            <html:select name="settingForecastForm" property="customer" styleClass="txfield" >
                <option value="All Customers">-- Select Customer --</option>
                <option value="All Customers"></option>
                <html:option value="Others">-- Others --</html:option>
                <html:options collection="customerList" property="value" labelProperty="label"/>
            </html:select>
            </logic:equal>
        </td>

        <td width="5%">&nbsp;</td>

        <td width="15%"> Product: </td>

        <td >
            <html:select name="settingForecastForm" property="product" styleClass="txfield" >
                <option value="-1">-- Select Product --</option>
                <option value="-1"></option>
                <html:options collection="productList" property="value" labelProperty="label"/>
            </html:select>

        </td>

    </tr>

    <tr>
        <td width="15%"> Start Month: </td>

        <td width="20%">
            <html:select name="settingForecastForm" property="startMonth" styleClass="txfield">
                <option value="-1">-- Select Month--</option>
                <option value="-1"></option>
                <html:options collection="monthList" property="value" labelProperty="label"/>
            </html:select>
        </td>

        <td width="5%">&nbsp;</td>

        <td width="15%"> Year: </td>
        <td >
            <html:select name="settingForecastForm" property="year" styleClass="txfield">
            <html:option value="-1">-Select-</html:option>
            <html:options collection="years" property="value" labelProperty="label" />
            </html:select>
        </td>

    </tr>

    <tr>
        <td width="15%"> Show next: </td>
        <td width="20%">
            <input type=text name="monthCount" value="6" maxlength="2" size="2" class="txfield" > months
        </td>
        <logic:equal name="settingForecastForm" property="showMkgForecast" value="on">
         <td width="5%">&nbsp;</td>
        <td colspan=2>
            &nbsp;
        </td>
        </logic:equal>

       <logic:notEqual name="settingForecastForm" property="showMkgForecast" value="on">
       <td width="5%">&nbsp;</td>
       <td width="15%"><font class="NArialL"><bean:message key="label.sales.endCustomer"/></font></td>
        <td >
            <html:select name="settingForecastForm" property="endUser" styleClass="txfield">
            <html:option value="">-Select <bean:message key="label.sales.endCustomer"/>-</html:option>
            <logic:present name="endUsersList">
            <html:options collection="endUsersList" property="value" labelProperty="label" />
            </logic:present>
            </html:select>
        </td>
        </logic:notEqual>

    </tr>

    <tr><td colspan=5 align="center">
       <%-- <A href="javascript:submitPage();"><IMG src="<%=chipTracContext%>/jsp/includes/images/submit.gif" border='0' onMouseOver="window.status='Click to Search for Forecast.';return true" onmouseout="window.status='';return true" title="Click here to Search for Forecast"></A> --%>
       <%--Modified by varma 27 jul 2004 --%>
        <input type=image border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17" onmouseover="window.status='Click to search for Forecast';return true" onmouseout="window.status='';return true" title="Click here to Search for Forecast">
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <A href="javascript:document.settingForecastForm.reset();"><IMG src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border='0' onMouseOver="window.status='Click to Reset.';return true" onmouseout="window.status='';return true" title="Click here to Reset"></A>
    </td></tr>

    <tr><td colspan=5><br><br></td></tr>

</Table>
<input type="hidden" name="action" value="">
<input type="hidden" name="marketing" value="<%=request.getParameter("marketing")%>">
</html:form>


<!-- till here -->

<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->

<%@ include file="/jsp/includes/footer.jsp" %>

<!-- footer end here -->

</BODY>
</HTML>
